<%@page import="com.ignou.mca.beans.SubjectBean"%>
<%@page import="com.ignou.mca.datasource.DatabaseOperations"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="theme/style.css"
	media="screen" />
<title>OES - Updating the subject details</title>
<script type="text/javascript">
	function resetHandle()
	{
		document.fm.subject.value="";
		document.fm.subject.focus();
	}
	
	function submitHandler()
	{
		var sub;
		sub = document.fm.subjectName.value;
		if(sub.length <1)
		{
			alert("Subject name cannot be emptied");
			document.fm.subjectName.focus();
			return false
		}
		else
		{
			return true;
		}
	}
</script>
</head>
<body>
	<div id="MainWrapper">
		<jsp:include page="header.jsp" /> 
		<jsp:include page="LeftContainer.jsp" />
		<div id="MainContent">
			<center>
			<h2>Update Subject details</h2>
			<%
				String subject= request.getParameter("subject");
				if(subject!=null)
				{
					int subId = Integer.parseInt(subject);
					DatabaseOperations dbOperations = new DatabaseOperations();
					SubjectBean sb = dbOperations.getSubjectDetails(subId);
					if(sb!=null)
					{
			%>
						<form action="Subjects.do" method="post" onsubmit="return submitHandler()" onreset="resetHandle()" name="fm">
							<input type="hidden" name="subjectId" value="<%=sb.getSubjectId() %>"/>
							<input type="hidden" name="command" value="update"/>
							<table>
								<tr><td> Subject Id:</td><td><input type="text" name="subject" value="<%=sb.getSubjectId() %>" disabled="disabled"/></td>
								<tr><td> Subject Name:</td><td><input type="text" name="subjectName" value="<%=sb.getSubjectName() %>"/></td>
								<tr><td></td><td><input type="submit" name="submit" value="Submit"/>
								<input type="reset" value="Reset"></td></tr>
							</table>
						</form>
			<%
					}
				}
			%>
			</center>
		</div>
		<jsp:include page="footer.jsp" />
	</div>
</body>
</html>